package com.easywan.vo;

import java.io.Serializable;

import com.easywan.vo.base.BaseModel;
/**
 * 衣服计算实体
 * @author T
 *	BUG
 *	小孩也应该有 上衣，衬衫，连衣裙，西装之内的
 *	该部分数据没有
 */
public class ToolsClothesSize extends BaseModel{
	private static final long serialVersionUID = 1L;
	private static final Integer MEN_UP_CLOTHES = 0x0;
	private static final Integer WOMEN_UP_CLOTHES = 0x10;
	private static final Integer MEN_SHIRT = 0x1;
	private static final Integer WOMEN_SHIRT = 0x11;
	private static final Integer MEN_PANTS = 0x2;
	private static final Integer WOMEN_PANTS = 0x12;
	private static final Integer MEN_SUIT = 0x3;
	private static final Integer WOMEN_SUIT = 0x13;
	private static final Integer WOMEN_DRESS = 0x14;
	private static final Integer BABY = 0x4;
	private static final Integer CHILDEN = 0x5;
	private static final Integer YOUNGER = 0x6;
	private static final Integer WOMEN_WX = 0x15;
	private static final Integer CHILDEN_CLOTHES = 0x7;
	private Integer type;
	private Integer height;
	private Integer weight;
	private Integer people;
	private String size;
	
	
	public Integer getPeople() {
		return people;
	}

	public void setPeople(Integer people) {
		this.people = people;
	}

	public static String getSize(Integer weight,Integer height,Integer people,Integer type) throws Exception{
		
		String size = null;
		int ci = 0;
		switch(type){
		case 0:switch(people){//成年男
			case 0:ci = MEN_UP_CLOTHES;break;//男上衣
			case 1:ci = MEN_SHIRT;break;//男衬衫
			case 2:ci = MEN_PANTS;break;//裤子
			case 3:ci = WOMEN_DRESS;break;//连衣裙
			case 4:ci = MEN_SUIT;break;//西装
			case 5:ci = BABY;break;//婴儿
			case 6:ci = CHILDEN;break;//小孩
			case 7:ci = YOUNGER;break;//青少年
			case 8:ci = CHILDEN_CLOTHES;break;
			}break;
		case 1:switch(people){//成年女
			case 0:ci = WOMEN_UP_CLOTHES;break;//上衣
			case 1:ci = WOMEN_SHIRT;break;//衬衫
			case 2:ci = WOMEN_PANTS;break;//裤子
			case 3:ci = WOMEN_DRESS;break;//连衣裙
			case 4:ci = WOMEN_SUIT;break;//西装
			case 5:ci = BABY;break;//婴儿
			case 6:ci = CHILDEN;break;//小孩
			case 7:ci = YOUNGER;break;//青少年
			case 8:ci = CHILDEN_CLOTHES;break;
			}break;
		case 2:switch(people){//成年男
		case 5:ci = BABY;break;//婴儿
		case 6:ci = CHILDEN;break;//小孩
		case 7:ci = YOUNGER;break;//青少年
		case 8:ci = CHILDEN_CLOTHES;break;
		}break;
		case 3:
			ci = WOMEN_WX;
		}
		Object[] sarr = {};
		if(ci == WOMEN_UP_CLOTHES || ci == WOMEN_SHIRT || ci == WOMEN_DRESS || ci == WOMEN_WX){
			sarr = new Object[]{"S", 80, 99, 145, 149, "S", 90, 99, 150, 169, "S", 80, 89, 160, 169, "M", 80, 99, 170, 172, "M", 90, 99, 173, 175, "M", 100, 109, 145, 149, "M", 100, 109, 155, 179, "L", 110, 119, 145, 149, "L", 110, 119, 155, 179, "L", 120, 129, 155, 159, "L", 120, 129, 170, 179, "XS", 80, 89, 150, 159, "XL", 110, 119, 150, 154, "XL", 120, 129, 145, 154, "XL", 120, 129, 160, 169, "XL", 130, 139, 160, 179, "XL", 140, 149, 173, 179, "XXL", 130, 139, 150, 159, "XXL", 140, 149, 155, 172};
		}else if(ci == MEN_UP_CLOTHES || ci == MEN_SHIRT || ci == MEN_PANTS || ci == MEN_SUIT){
			sarr = new Object[]{44, 85, 115, 153, 163, 44, 85, 105, 163, 168, 44, 85, 95, 168, 173, 46, 115, 135, 153, 163, 46, 135, 145, 153, 158, 46, 105, 125, 163, 168, 46, 95, 115, 168, 173, 46, 95, 105, 173, 178, 48, 145, 165, 153, 158, 48, 135, 155, 158, 163, 48, 125, 145, 163, 168, 48, 115, 145, 168, 173, 48, 105, 125, 173, 178, 48, 105, 115, 178, 183, 50, 165, 185, 153, 158, 50, 155, 175, 158, 163, 50, 145, 165, 163, 168, 50, 145, 155, 168, 173, 50, 125, 155, 173, 178, 50, 115, 135, 178, 183, 50, 115, 125, 183, 188, 52, 175, 195, 158, 163, 52, 165, 185, 163, 168, 52, 155, 175, 168, 173, 52, 155, 165, 173, 183, 52, 135, 155, 178, 183, 52, 125, 145, 183, 188, 52, 125, 135, 188, 193, 54, 185, 195, 163, 173, 54, 175, 185, 168, 178, 54, 165, 175, 173, 188, 54, 145, 165, 183, 188, 54, 135, 155, 188, 193, 56, 195, 215, 168, 183, 56, 185, 195, 173, 193, 56, 175, 185, 178, 193, 56, 155, 175, 188, 193, 58, 195, 215, 183, 193};
		}else if(ci == BABY || ci == CHILDEN || ci == YOUNGER || ci == CHILDEN_CLOTHES){
			sarr = new Object[]{59, 6, 11, 55, 62, 66, 12, 14, 55, 62, 66, 8, 16, 63, 69, 73, 17, 20, 63, 69, 73, 12, 20, 70, 76, 80, 21, 24, 70, 76, 80, 16, 24, 77, 83, 90, 23, 28, 77, 83, 90, 20, 30, 84, 94, 100, 31, 36, 84, 94, 100, 22, 38, 95, 104, 110, 39, 44, 95, 104, 110, 26, 42, 105, 114, 120, 43, 52, 105, 114, 120, 34, 52, 115, 124, 130, 53, 60, 115, 124, 130, 40, 60, 125, 134, 140, 61, 80, 125, 134, 140, 52, 76, 135, 144, 150, 77, 90, 135, 144, 150, 70, 84, 145, 154, 160, 85, 100, 145, 154, 160, 80, 110, 155, 164, 165, 111, 130, 155, 164};
		}else if(ci == CHILDEN_CLOTHES){
			 sarr = new Object[]{"32/70A", 68, 72, 80, 82, "32/70B", 68, 72, 83, 84, "32/70C", 68, 72, 85, 87, "32/70D", 68, 72, 88, 88, "34/75A", 73, 77, 85, 87, "34/75B", 73, 77, 88, 89, "34/75C", 73, 77, 90, 94, "34/75D", 73, 77, 95, 97, "34/75E", 73, 77, 98, 98, "36/80A", 78, 82, 90, 92, "36/80B", 78, 82, 93, 94, "36/80C", 78, 82, 95, 97, "36/80D", 78, 82, 98, 102, "36/80E", 78, 82, 103, 103, "38/85A", 83, 87, 95, 97, "38/85B", 83, 87, 99, 101, "38/85C", 83, 87, 101, 103, "38/85D", 83, 87, 103, 105, "40/90B", 88, 92, 103, 104, "40/90C", 88, 92, 105, 107, "40/90D", 88, 92, 108, 112, "40/90E", 88, 92, 113, 113};
		}else{
			
		}
		for(int i = 0; i < sarr.length/5; i++){
			Integer w1 = (Integer) sarr[5 * i + 1];
			Integer w2 = (Integer) sarr[5 * i + 2];
			Integer h1 = (Integer) sarr[5 * i + 3];
			Integer h2 = (Integer) sarr[5 * i + 4];
			if(weight >= w1 && weight >= w2 && height >= h1 && height <= h2){
				size =  sarr[5*i].toString();
				break;
			}
			if(i == sarr.length / 5 - 1){
				throw new Exception("还没有收录该条件配型的型号的数据，如果你通过其它的渠道了解到了，欢迎在下面反馈区反馈给我们，我们感激不尽！");
			}
		}
		if(ci == WOMEN_WX){//文胸
			switch (size) {
            case "XS":size = "24/25"; break;
            case "S": size = "25/26"; break;
            case "M": size = "27/28"; break;
            case "L": size = "29/30"; break;
            case "XL": size = "31/32"; break;
            case "XXL":  size = "33/34"; break;
			}
		}
		if (ci == MEN_UP_CLOTHES) { //男衣服
	        switch (size) {
	            case "44":size = "XS"; break;
	            case "46": size = "S";break;
	            case "48":  size = "M";break;
	            case "50":  size = "L";break;
	            case "52": size = "XL";break;
	            case "54": size = "XXL";break;
	            case "56": size = "XXXL";break;
	        }
	    }
	    if (ci == MEN_SHIRT) { //男衬衫
	        switch (size) {
	            case "44": size = "37"; break;
	            case "46": size = "38"; break;
	            case "48": size = "39"; break;
	            case "50": size = "40"; break;
	            case "52": size = "41"; break;
	            case "54": size = "42"; break;
	            case "56": size = "43"; break;
	        }
	    }
	    if (ci == MEN_PANTS) { //男裤子
	        switch (size) {
	            case "44": size = "27"; break;
	            case "46": size = "28/29/30"; break;
	            case "48": size = "30/31/32"; break;
	            case "50": size = "33/34"; break;
	            case "52": size = "35/36"; break;
	            case "54": size = "38"; break;
	            case "56": size = "40"; break;
	        }
	    }
	    return size;
	}
	
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Integer getHeight() {
		return height;
	}
	public void setHeight(Integer height) {
		this.height = height;
	}
	public Integer getWeight() {
		return weight;
	}
	public void setWeight(Integer weight) {
		this.weight = weight;
	}
	public String getSize() {
		if(size != null) return size;
		try{
			ToolsClothesSize.getSize(weight, height, people, type);
		}catch(Exception e){
			size = e.getMessage();
		}
		return size;
	}
	public void setSize(String size) {
		this.size = size;
	}
	
	
}
